<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <textarea id="ta" width="500px" height="500px;"></textarea>
    <input type="button" value="存储" id="btn">
</body>


<script>

    window.onload = function () {
        var ta = document.getElementById('ta');

        var btn = document.getElementById('btn');

        if(localStorage.text){
            ta.value = localStorage.text;
        }

        btn.onclick = function () {
            localStorage.text = ta.value;
        }

    }

</script>
</html>